<template>
	<view class="mine">
		<view class="mine-bg"></view>
		<uni-nav-bar
			statusBar="true"
			:fixed="true"
			backgroundColor="transparent"
			:border="false"
			title="爱牙大使"
			color="white"
			left-icon="left"
			@clickLeft="backTo"
		></uni-nav-bar>
		<view class="mine-header">
			<image :src="content.avatar" mode="aspectFill" class="header-logo"></image>
			<view class="header-info">
				<view class="h2">{{ content.userName || '' }}</view>
				<view class="info-tags">
					<view class="tags-item">{{ content.memberLevel || '' }}</view>
					<!-- <view class="tags-item">点亮荷花</view> -->
				</view>
			</view>
			<view class="header-handle">
				<!-- <uni-badge class="uni-badge-left-margin" :text="8" :offset="[8, 8]" absolute="rightTop" size="small">
					<image src="@/static/mine/info@2x.png" class="img" mode="aspectFill"></image>
				</uni-badge> -->
				<!-- <button class="button" open-type="contact">
					<image src="@/static/contact-white.png" class="img" mode="aspectFill"></image>
				</button>
				 -->
			</view>
		</view>
		<view class="mine-main">
			<div class="main-card">
				<!-- <view class="card-ad">
					<view class="ad-info">
						<view class="h2">成为牙荷体验官，享受专属福利</view>
						<view class="p">最低99元，全城免费洁牙一次</view>
					</view>
					<view class="ad-button">成为体验官</view>
				</view> -->
				<view class="benefit">
					<view class="label">累计福利金（元）</view>
					<view class="num">{{content.totalPrice || 0}}</view>
				</view>
				<view class="benefit-specific">
					<view class="list-item">
						<view class="list-label">可提现福利金（元）</view>
						<view class="list-value">
							<view class="num">{{content.withdrawal || 0}}</view>
							<view class="tags-item" @click="handleToUrl('/mineComponentPackage/component/withdraw/index')">提现</view>
						</view>
					</view>
					<view class="list-border"></view>
					<view class="list-item">
						<view class="list-label">待结算福利金（元）</view>
						<view class="num">{{content.settlePrice || 0}}</view>
					</view>
				</view>
			</div>
			<div class="main-card-2">
				<view class="list-item" @click="handleToUrl('/mineComponentPackage/component/promotionOrder/index')">
					<view class="list-label" >推广订单</view>
					<view class="num">{{content.orderCount || 0}}</view>
				</view>
				<view class="list-item" @click="handleToUrl('/mineComponentPackage/component/friend/index')">
					<view class="list-label">我的荷友</view>
					<view class="num">{{content.lotusFriend || 0}}</view>
				</view>
				<view class="list-item" @click="handleToUrl('/mineComponentPackage/component/lotus/index')">
					<view class="list-label">荷花</view>
					<view class="num">{{content.lotusCount || 0}}</view>
				</view>
			</div>
			<!-- <image src="https://fine-yahe.oss-cn-shanghai.aliyuncs.com/app/inclusive/lianmi.png" mode="aspectFill" class="red-envelope"></image> -->
			<view class="main-cate">
				<view class="title">更多服务</view>
				<view class="cate-list">
					<!-- <view class="list-item">
						<view class="list-value">
							<view class="label">学习中心</view>
							<view class="value">回馈金享不停</view>
						</view>

						<image src="@/static/mine/service.png" mode="aspectFill" class="img"></image>
					</view> -->
					<view class="list-item" @click="handleToUrl('/mineComponentPackage/ambassador/promotionPoster')">
						<view class="list-value">
							<view class="label">推广海报</view>
							<view class="value">回馈金享不停</view>
						</view>
						<image src="@/static/mine/service.png" mode="aspectFill" class="img"></image>
					</view>
					<button open-type="share" class="list-item openBtn">
						<view class="list-value">
							<view class="label" @click="invite">邀请荷友</view>
							<view class="value">回馈金享不停</view>
						</view>
						<image src="@/static/mine/service.png" mode="aspectFill" class="img"></image>
					</button>
				</view>
			</view>
			<view class="main-cate">
				<view class="title">奖励任务</view>
				<view class="card-task">
					<!-- <image src="" mode="" class="task-img"></image> -->
					<view class="task-content">
						<view class="task-title">邀请牙科商务入驻牙荷</view>
						<view class="task-decr">这里是副标</view>
						<view class="task-mony">最高奖励¥500</view>
						<view class="task-bottom">
							<view class="task-day">任务可进行两天</view>
							<view class="task-btn" @click="handleToUrl('/mineComponentPackage/serviceCentre/institution?type=2')">立即参与</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			content: {},
		};
	},
	onLoad() {
		uni.showLoading({
			title: '加载中'
		});
		this.$post('/yahe/promotion/ambassador', {}, '1')
			.then((res) => {
				if (res.success) {
					this.content = res.content;
				}
			})
			.catch((res) => {
				uni.showToast({
					title: res.message,
					icon: 'none'
				});
			});
	},
	onShareAppMessage(res) {
		return {
			title: '牙荷',
			path: `/pages/index/index?source=1&invite_uid=${uni.getStorageSync('user').userId}`,
			imageUrl: 'https://fine-yahe.oss-cn-shanghai.aliyuncs.com/app/ambassador/fenxiang.png'
		}
	},
	methods: {
		backTo() {
			if (getCurrentPages().length > 1) {
				uni.navigateBack({
					delta: 1 // 返回上一页
				});
			} else {
				uni.switchTab({
					url: '/pages/index/index'
				});
			}
		},
		handleToUrl(url) {
			uni.navigateTo({
				url
			});
		},
		invite() {
			// wx.shareAppMessage({
			// 	title: '牙荷',
			// 	path: '/pages/index/index'
			// });
		}
	}
};
</script>

<style lang="less" scoped>
.mine {
	background: #f5f5f5;
	// height: 95vh;
	height: 100%;
	// padding-bottom: 20rpx;
	.mine-bg {
		width: 100%;
		height: 460rpx;
		// background: var(--theme-color);
		background: #10beaf;
		position: absolute;
		top: 0;
		left: 0;
		right: 0;
	}

	.mine-header {
		display: flex;
		align-items: center;
		padding: 8rpx 24rpx;
		color: #fff;
		position: relative;
		z-index: 10;
		top: 28rpx;

		.header-logo {
			width: 108rpx;
			height: 108rpx;
			border-radius: 50%;
			border: 4rpx solid rgba(255, 255, 255, 0.4);
		}

		.header-info {
			flex: 1;
			margin-left: 28rpx;
			margin-right: auto;

			.h2 {
				font-size: 28rpx;
				font-weight: bold;
			}

			.info-tags {
				margin-top: 8rpx;
				display: flex;
				align-items: center;

				.tags-item {
					line-height: 1;
					padding: 8rpx 12rpx;
					border-radius: 30rpx;
					background: rgba(255, 255, 255, 0.27);
					margin-right: 6rpx;
					font-size: 20rpx;
				}
			}
		}

		.header-handle {
			display: flex;
			align-items: center;

			.button {
				margin: 0 28rpx;
				line-height: 1;
				padding: 0;
			}

			.img {
				width: 64rpx;
				height: 64rpx;
				display: block;
			}
		}
	}

	// mine-header end

	.mine-main {
		margin-top: 58rpx;
		padding: 0 24rpx;
		position: relative;
		z-index: 11;
		// padding-bottom: 30rpx;
		// background-color: #f5f5f5;
	}

	.red-envelope {
		width: 100%;
		height: 152rpx;
		background: #d9d9d9;
		border-radius: 20rpx 20rpx 20rpx 20rpx;
	}

	.main-card-2 {
		display: flex;
		justify-content: space-between;
		background-color: white;
		border-radius: 20rpx;
		padding: 20rpx;
		margin: 20rpx 0rpx;

		.list-item:first-child {
			border: none;
		}

		.list-item {
			flex: 1;
			color: #b0b0b0;
			font-size: 26rpx;

			border-left: 2rpx solid #efefef;
			padding-left: 20rpx;

			.num {
				font-size: 30rpx;
				color: black;
				font-weight: 800;
			}
		}
	}

	.main-card {
		background: linear-gradient(176deg, #e5fffd 0%, #ffffff 24%, #ffffff 100%);
		box-shadow: 0rpx 6rpx 6rpx 0rpx rgba(0, 0, 0, 0.04);
		border-radius: 20rpx;
		overflow: hidden;
		padding: 20rpx;

		.benefit {
			display: flex;
			justify-content: space-between;
			border-bottom: 2rpx solid #efefef;
			padding-bottom: 20rpx;
			font-size: 30rpx;
		}

		.num {
			font-weight: 800;
			margin-right: 10rpx;
		}

		.label {
			color: #3a3a3a;
		}

		.benefit-specific {
			display: flex;
			justify-content: space-between;
			padding-top: 20rpx;

			.list-item {
				.list-value {
					display: flex;
					align-items: center;
				}

				.list-label {
					font-size: 26rpx;
					color: #b0b0b0;
				}
			}

			.list-border {
				width: 2rpx;
				background-color: #efefef;
			}

			.tags-item {
				// line-height: 1;
				padding: 0rpx 20rpx;
				border-radius: 58rpx;
				background: #10beaf;
				margin-right: 6rpx;
				font-size: 20rpx;
				color: white;
				height: 36rpx;
				line-height: 36rpx;
			}
		}

		.card-ad {
			display: flex;
			align-items: center;
			background: linear-gradient(90deg, #ffe3d6 0%, #fff4e2 100%);
			padding: 20rpx 30rpx 10rpx;

			.ad-info {
				.h2 {
					font-size: 24rpx;
					color: var(--title-color);
					margin-bottom: 4rpx;
				}

				.p {
					font-size: 20rpx;
					color: #f07676;
				}
			}

			.ad-button {
				height: 56rpx;
				line-height: 56rpx;
				background: linear-gradient(90deg, #ffad6a 0%, #ff7745 100%);
				color: #fff;
				font-size: 24rpx;
				padding: 0 20rpx;
				border-radius: 100rpx;
				margin-left: auto;
			}
		}

		.card-list {
			display: flex;
			align-items: center;
			padding: 20rpx 0;
			justify-content: space-evenly;

			.list-item {
				font-size: 24rpx;
				color: #6d6d6d;
				text-align: center;

				.num {
					font-size: 28rpx;
					font-weight: bold;
					color: var(--title-color);
					margin-bottom: 8rpx;
				}

				.imgTitle {
					width: 214rpx;
					height: 107rpx;
				}
			}
		}
	}

	// main-card end

	.main-order {
		margin-bottom: 24rpx;

		.order-title {
			display: flex;
			align-items: center;
			font-size: 28rpx;
			color: var(--title-color);
			line-height: 88rpx;
			font-weight: bold;

			.title-span {
				display: flex;
				align-items: center;
				font-weight: 400;
				font-size: 24rpx;
				color: #6d6d6d;
				margin-left: auto;
			}
		}

		.order-list {
			display: flex;
			align-items: center;
			justify-content: space-evenly;

			.list-item {
				font-size: 24rpx;
				color: var(--title-color);
				text-align: center;

				.img {
					display: block;
					width: 76rpx;
					height: 76rpx;
					margin: 0 auto;
					margin-bottom: 12rpx;
				}
			}
		}
	}

	// main-order end

	.main-banner {
		width: 100%;
		height: 98rpx;
		border-radius: 98rpx;
		overflow: hidden;

		.img {
			width: 100%;
			height: 100%;
		}
	}

	.main-cate {
		.title {
			font-size: 28rpx;
			color: var(--title-color);
			line-height: 88rpx;
			font-weight: bold;
		}

		.card-task {
			display: flex;
			// justify-content: space-between;
			background-color: white;
			gap: 20rpx;
			padding: 20rpx;
			border-radius: 20rpx 20rpx 20rpx 20rpx;

			.task-img {
				width: 170rpx;
				height: 170rpx;
				background: #cccccc;
				border-radius: 8rpx 8rpx 8rpx 8rpx;
			}

			.task-content {
				display: flex;
				flex-direction: column;
				flex: 1;
				font-family: HarmonyOS Sans SC, HarmonyOS Sans SC;
				gap: 5rpx;

				.task-title {
					font-weight: 500;
					font-size: 28rpx;
					color: #3a3a3a;
				}

				.task-decr {
					font-weight: 400;
					font-size: 22rpx;
				}

				.task-mony {
					font-weight: 400;
					font-size: 22rpx;
					color: #ff6737;
					width: 144rpx;
					height: 26rpx;
					line-height: 26rpx;
					border-radius: 4rpx 4rpx 4rpx 4rpx;
					border: 1rpx solid #ff6737;
				}

				.task-bottom {
					display: flex;
					justify-content: space-between;
					align-items: center;

					.task-day {
						font-size: 24rpx;
						color: #b0b0b0;
					}

					.task-btn {
						width: 136rpx;
						height: 52rpx;
						border-radius: 40rpx 40rpx 40rpx 40rpx;
						border: 1rpx solid #10beaf;
						font-weight: 400;
						font-size: 24rpx;
						color: #0a978e;
						line-height: 52rpx;
						text-align: center;
					}
				}
			}
		}

		.cate-list {
			display: flex;
			flex-wrap: wrap;
			justify-content: space-between;

			.openBtn {
				line-height: inherit;
				text-align: left;
				box-sizing: content-box;
			}

			.list-item {
				width: 43%;
				display: flex;
				align-items: center;
				margin-bottom: 12rpx;
				font-size: 24rpx;
				color: var(--title-color);
				padding: 20rpx;
				display: flex;
				justify-content: space-between;
				background: linear-gradient(143deg, #ffffff 0%, #eef7ff 100%);
				border-radius: 20rpx 20rpx 20rpx 20rpx;
				border: 2rpx solid #ffffff;

				.list-value {
					display: flex;
					flex-direction: column;

					.label {
						font-size: 26rpx;
						font-weight: 800;
					}

					.value {
						font-size: 22rpx;
						color: #b0b0b0;
					}
				}

				.img {
					width: 56rpx;
					height: 56rpx;
					margin-right: 8rpx;
				}
			}
		}
	}
}
</style>
